package yeliuhuishi.TopMovie;

import lombok.Data;
import org.apache.hadoop.io.WritableComparable;
import org.jetbrains.annotations.NotNull;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
public class RateBean implements WritableComparable<RateBean> {
    private String movie;//电影
    private String rate;//率
    private String timeStamp;//时标
    private String uid;//


    public int compareTo(@NotNull RateBean o) {
        return -this.rate.compareTo(o.rate);
    }

    public void write(DataOutput out) throws IOException {
        out.writeUTF(movie);
        out.writeUTF(rate);
        out.writeUTF(timeStamp);
        out.writeUTF(uid);
    }

    public void readFields(DataInput in) throws IOException {
        this.movie = in.readUTF();
        this.rate = in.readUTF();
        this.timeStamp = in.readUTF();
        this.uid = in.readUTF();
    }

    @Override
    public String toString() {
        return movie;
    }

    String getMovie() {
        return movie;
    }

    void setMovie(String movie) {
        this.movie = movie;
    }

    public String getRate() {
        return rate;
    }

    void setRate(String rate) {
        this.rate = rate;
    }

    String getTimeStamp() {
        return timeStamp;
    }

    void setTimeStamp(String timeStamp) {
        this.timeStamp = timeStamp;
    }

    String getUid() {
        return uid;
    }

    void setUid(String uid) {
        this.uid = uid;
    }
}
